package arm.admin.entity;

import arm.common.entity.ABaseEntity;

import javax.persistence.*;

@Entity
@Table(name = "USERS")
public class Users extends ABaseEntity
{
    private String login;
    private String password;
    private String surname;
    private String firstname;
    private String patronymic;
    private String role;

    @Basic
    @Column(name= "LOGIN")
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    @Basic
    @Column(name= "PASSWORD")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name= "SURNAME")
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    @Basic
    @Column(name= "FIRSTNAME")
    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    @Basic
    @Column(name= "PATRONYMIC")
    public String getPatronymic() {
        return patronymic;
    }

    public void setPatronymic(String patronymic) {
        this.patronymic = patronymic;
    }

    @Basic
    @Column(name= "ROLE")
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Transient
    public String getRoleString()
    {
        String result = "";
        if (getRole() != null && getRole().equals("ROLE_USER"))
        {
            return "Пользователь";
        }
        else
        if (getRole() != null && getRole().equals("ROLE_ADMIN"))
        {
            return "Администратор";
        }
        return "";
    }

}